

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        StringBuilder sb=new StringBuilder();
        while(n>0)
        {
            int a=n%2;
            sb.append(a+"");
            n=n/2;
        }
        sb.reverse();
        String str=sb.toString();
        char[] ch=str.toCharArray();

        int count=0;
        int ret=0;

        for(int i=0;i<ch.length;i++)//1110101
        {
            if(ch[i]=='1')
            {
                count++;//2//1
            }
            if(ch[i]=='0')
            {
                if(count>ret)
                {
                    ret=count;//2

                }
                count=0;
            }
        }
        if(count>=ret)
        {
            ret=count;
        }
        System.out.println(ret);
    }
}


/*
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        String str1=Integer.toBinaryString(n);
        String[] str=str1.split("0");
        int count=0;
        for(int i=0;i<str.length;i++)
        {
            if(str[i].length()>count)
            {
                count=str[i].length();
            }

        }
        System.out.println(count);
    }
}
 */


/*
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
       int n=in.nextInt();
       int count=0;
       int ret=0;
       while(n!=0)
       {
        if((n&1)==1)
        {
            count++;
        }
        if((n&1)==0)
        {
            if(count>ret)
            {
                ret=count;
            }
            count=0;
        }
        n=n>>1;

       }
       if(count>ret)
       {
        ret =count;
       }
       System.out.println(ret);
    }
}
 */